package com.kingyun.gpsinspection.purificationservice.common.enums;

/**
 * Created by sugongche on 2016/12/1.
 */
public enum FileTypeUtilEnum {
    _TXT(1, "txt"),
    _DOC(2, "doc"),
    _DOCX(3, "docx"),
    _XLS(4, "xls"),
    _XLSX(5, "xlsx"),
    _PPT(6, "ppt"),
    _PPTX(7, "pptx"),
    _RAR(8, "rar"),
    _PDF(9, "pdf"),
    _ZIP(10, "zip"),
    _RM(11, "rm"),
    _RMVB(12, "rmvb"),
    _WMV(13, "wmv"),
    _AVI(14, "avi"),
    _MP4(15, "mp4"),
    _MKV(16, "mkv"),
    _GIF(17, "gif"),
    _JPG(18, "jpg"),
    _JPEG(19, "jpeg"),
    _BMP(20, "bmp"),
    _PNG(21, "png");
    private int code;
    private String description;

    FileTypeUtilEnum(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public static String getDescription(int code) {
        for (FileTypeUtilEnum t : FileTypeUtilEnum.values()) {
            if (t.getCode() == code) {
                return t.getDescription();
            }
        }
        return null;
    }

    public static int getCode(String description){
        for (FileTypeUtilEnum t : FileTypeUtilEnum.values()) {
            if (t.getDescription().equals(description)) {
                return t.getCode();
            }
        }
        return -1;
    }
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public int code() {
        return code;
    }

    public String description() {
        return description;
    }
}
